<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

</head>
<body>
    <div id="app">
        <p v-for="(item,index) in list">{{index+1}}----{{item}}</p>
        <button @click="changeList">切片</button>
    </div>    

    <script>
        

        var app = new Vue({
            el:"#app",
            data:{
                list:["三国演义","水浒传","西游记","红楼梦"],
              
            },
            methods: {
                changeList(){
                    this.list = this.list.slice(0,2);
                    this.list.push("push");
                }
            },
            // 控制台上直接修改app.list[]元素，不会动态刷新
            // 解决方案
            // 1.调用splice方法，Vue进行包裹可直接动态刷新
            // 2.调用$forceUpdate()方法强制进行刷新
            // 3.Vue.set(app.list,indexOf,newValue)
            // 4.app.$set(app.list,indexOf,newValue)
           
        });
    </script>
</body>
</html>
